<?php

namespace app\api\controller;

use app\api\service\ProductService;
use app\BaseController;
use app\Response;
use think\facade\Request;

class Product extends BaseController
{
    /** 产品列表
     * @return json
    */
    public function productList(){
        $page = Request::post("page",1);
        $num = Request::post("num",10);
        $key = Request::post("keyword","");
        $class_one  = Request::post("class_one","");
        $price_sort = Request::post("price_sort","");//1从低到高 2从高到低
        $commission_sort = Request::post("commission_sort");//1从低到高 2从高到低
        list($data,$count) = ProductService::productList($page,$num,$key,$class_one,$price_sort,$commission_sort);
        return Response::wrapData($data,$count);
    }


    /** 产品详情
     * @return json
     */
    public function procutInfo(){
        $id = Request::post("id","");
        if (empty($id)){
            return Response::wrapError("信息异常!");
        }
        $info = ProductService::productDetailed($id);
        return Response::wrapData($info);
    }
}